package model

import "kpt-dtm/model/yyn"

type DryMatter struct {
	Id         int   `json:"id"`
	PastureId  int64 `json:"pasture_id"`
	ElabLoadId int64 `gorm:"column:elabLoad_id" json:"elabLoad_id"`
	CreatedAt  int64 `json:"created_at"`
	UpdatedAt  int64 `json:"updated_at"`
}

func (d *DryMatter) TableName() string {
	return "d_dry_matter"
}

func NewDryMatter(pastureId, elabLoadId int64) *DryMatter {
	return &DryMatter{
		PastureId:  pastureId,
		ElabLoadId: elabLoadId,
	}
}

func NewDryMatterList(pastureId int64, res []*yyn.DryMatter) []*DryMatter {
	var dryMatterList = make([]*DryMatter, 0)
	for _, v := range res {
		dryMatterList = append(dryMatterList, NewDryMatter(pastureId, v.ElabLoadId))
	}
	return dryMatterList
}
